layui.use(['common', 'jquery', 'laydate', 'form'], function () {
    let $ = layui.jquery;
    let common = layui.common;
    let from = layui.form;

    let laydate = layui.laydate;

    let lat = $("#map").data('lat');
    let lon = $("#map").data('lon');

    laydate.render({
        elem: '#start' //指定元素
    });
    laydate.render({
        elem: '#end' //指定元素
    });
    common.gMap(lon, lat, "map");
    from.on("submit(getTotal)", function (data) {
        let url = $("#serch_biz").attr('action');
        // 获取开始时间
        let start_time = data.field['start'];
        // 获取结束时间
        let end_time = data.field['end'];
        $.ajax({
            url: url,
            type: 'get',
            headers: {
                'type': 'ajax'
            },
            data: {
                start: start_time,
                end: end_time
            },
            dataType: 'json',
            success: function (res) {
                if (res.code === 0){
                    $("#wx_pay").children('span').text(Number(res.data['wx_turnover']).toFixed(2));
                    $("#al_pay").children('span').text(Number(res.data['ali_turnover']).toFixed(2));
                    $("#total").children('span').text(Number(res.data['total']).toFixed(2));
                    $("#money_back").children("span").text(Number(res.data['money_back']).toFixed(2));
                }
            }
        });
        return false;
    });
});
